<!DOCTYPE html>
<html>
   <head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>AmazeUI-2.7.2</title>
		<!--  -->
      <script src="../assets/js/jquery-3.4.1.min.js"></script>
		<!-- 引入CSS -->
        <link rel="stylesheet" href="../assets/css/amazeui.min.css">
		<!-- 引入JS -->
      <script src="../assets/layer/layer.js"></script>
	</head>
    
<body>
<div id="app">

   <form class="am-form">
      <fieldset>
         <div class="am-form-group">
            <label for="doc-ipt-email-1">片段名称</label>
            <input type="text" class=""  id="title" placeholder="片段名称">
         </div>
         


         <div class="am-form-group">
            <label for="doc-ta-1">片段内容</label>
            <textarea class="" rows="10" id="content" placeholder="片段内容"></textarea>
          </div>

          <button type="button" onclick="fromSubmit()" class="am-btn am-btn-primary">提交</button>
       
      </fieldset>
    </form>


</div>
<script>
(()=>{
   console.log('parent',parent.VM.updateData);
   let title=parent.VM.updateData.description;
   $('#title').val(title);
   $('#content').val(parent.VM.updateData.files[title].content);
})();
function fromSubmit(){
   console.log('1');
   console.log(parent);
   let insertData={
      id:parent.VM.updateData.id,
      title:$('#title').val(),
      content:$('#content').val(),
   }
   parent.gitee.updateCode(insertData).then((res)=>{
                console.log("res",res);
                layer.msg('修改成功!');
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭    
                parent.VM.refreshList();
   });
   //console.log(insertData);
   

   //var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
   //parent.layer.close(index); //再执行关闭    
};

</script>

</body>
</html>